package org.meb.speedway.web;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import lombok.Getter;

import org.meb.speedway.bean.SearchService;
import org.meb.speedway.model.registry.League;
import org.meb.speedway.query.LeagueQuery;

@Named
@ViewScoped
public class LeaguesBean implements Serializable {

	private static final long serialVersionUID = 1861234019303306500L;

	@Inject
	private SearchService searchService;

	@Getter
	private List<League> leagues;

	@SuppressWarnings("unused")
	@PostConstruct
	private void initialize() {
		LeagueQuery query = new LeagueQuery();
		query.getSortOrder().asc("name");
		leagues = searchService.find(query);
	}
}
